//
//  AgreementViewController.m
//  QT
//
//  Created by 甘世清 on 2025/1/7.
//

#import "AgreementViewController.h"
#import "AgreementCollectionViewCell.h"
#import "CommonWebVcView.h"
@interface AgreementViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>

@end

@implementation AgreementViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.zx_navTitle = SQNSLocalString(@"协议");
    // Do any additional setup after loading the view.
}
- (void)SQ_UIViewForSelfView{
    self.collectionView.backgroundColor = UIColor.whiteColor;
    [self.collectionView registerClass:[AgreementCollectionViewCell class] forCellWithReuseIdentifier:@"AgreementCollectionViewCell"];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    [self.view addSubview:self.collectionView];
    [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self.view);
        make.top.equalTo(self.zx_navBar.mas_bottom);
    }];
    self.jsonArray = [[NSMutableArray alloc]initWithObjects:@"用户协议",@"隐私协议", nil];
    [self.collectionView reloadData];
}

#pragma mark UICollectionViewDelegate,UICollectionViewDataSource
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
   
    return self.jsonArray.count;
}

-(UICollectionViewCell *)collectionView:(UICollectionView*)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath{
    AgreementCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AgreementCollectionViewCell" forIndexPath:indexPath];
    cell.nameLabel.text = [self.jsonArray objectAtIndex:indexPath.item];
     return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    CGFloat w = SCREEN_WIDETH/2.f-15;
    return CGSizeMake(w, 50);
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
    return 10;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    return 0;
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return UIEdgeInsetsMake(10, 10, 0, 10);
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
   
    CommonWebVcView * vc = [[CommonWebVcView alloc]init];
    vc.urlStr = @"https://www.baidu.com";
    [self SQ_pushViewControllerFull:vc];
}
@end
